#ifndef YCCORERECORDINFO_H
#define YCCORERECORDINFO_H

#include "modeltype.h"
#include <QJsonObject>

namespace yc {

struct RecordInfo
{
    int id;
    int presenter;
    int live;
    QDateTime start_time;
    int duration;
    QString url;
    int category;
    int status;

    RecordInfo() : id(0), presenter(0), live(0), duration(0), category(0), status(0) { }
    explicit RecordInfo(const QJsonObject& jo) { this->operator=(jo); }

    RecordInfo& operator=(const QJsonObject& jo)
    {
        id = jo["id"].toInt();
        presenter = jo["presenter"].toInt();
        live = jo["live"].toInt();
        start_time = QDateTime::fromString(jo["startTime"].toString(), Qt::ISODate);
        duration = jo["duration"].toInt();
        url = jo["url"].toString();
        category = jo["category"].toInt();
        status = jo["status"].toInt();
        return *this;
    }

    QJsonObject toJsonObject() const
    {
        return QJsonObject { { "id", id },
                             { "presenter", presenter },
                             { "live", live },
                             { "startTime", start_time.toString(Qt::ISODate) },
                             { "duration", duration },
                             { "url", url },
                             { "category", category },
                             { "status", status } };
    }
};

} // namespace yc

#endif // YCCORERECORDINFO_H
